<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var canChoose = function (groups, nums) {
      let cur = 0;
      const num = nums.join("");
      let last = 0; // 记录上一次的位置
      for (let i = 0; i < groups.length; i++) {
        const group = groups[i].join("");
        const index = num.indexOf(group, last);
        if (index === -1) return false;
        else {
          last = index + group.length;
        }
      }
      return true;
    };
    console.log(canChoose([[1, -1, -1], [3, -2, 0]], [1, -1, 0, 1, -1, -1, 3, -2, 0]));
  </script>
</body>

</html>